package com.start.code.generator.configs;

import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
@ConfigurationProperties(prefix = "start.code.generator")
public class StartCodeTemplateConfig {
    private Boolean enable = false;
    private String codeTemplateDir = "default/codeTemplate/";
    public static final String JAVA_ENTITY_VM = "Entity.java.vm";
    public static final String JAVA_MAPPER_VM = "Mapper.java.vm";
    public static final String JAVA_SERVICE_VM = "Service.java.vm";
    public static final String JAVA_SERVICE_IMPL_VM = "ServiceImpl.java.vm";
    public static final String JAVA_CONTROLLER_VM = "Controller.java.vm";
    public static final String XML_MAPPER_VM = "Mapper.xml.vm";
    public static final String VUE_INDEX_VM = "index.vue.vm";
    public static final String JS_API_VM = "Api.js.vm";
    public static final String JS_Option_VM = "Option.js.vm";

    public List<String> getCodeTemplates() {
        if (StringUtils.isEmpty(codeTemplateDir)) {
            throw new RuntimeException("代码模板路径不能为空");
        }
        return new ArrayList<String>() {
            {
                add(codeTemplateDir + JS_API_VM);
                add(codeTemplateDir + JS_Option_VM);
                add(codeTemplateDir + VUE_INDEX_VM);
                add(codeTemplateDir + JAVA_CONTROLLER_VM);
                add(codeTemplateDir + JAVA_ENTITY_VM);
                add(codeTemplateDir + JAVA_MAPPER_VM);
                add(codeTemplateDir + XML_MAPPER_VM);
                add(codeTemplateDir + JAVA_SERVICE_VM);
                add(codeTemplateDir + JAVA_SERVICE_IMPL_VM);
            }
        };
    }

}
